package com.lagou.task01;

/**
 *
 * 编程统计字符串 "ABCD123!@#$ab"中大写字母、小写字母、数字、其他字符的个数并打印
 *
 * */

public class StatisticsTest {

    public static void main(String[] args){

        String str = "ABCD123!@#$ab";

        int big = 0;
        int small = 0;
        int number = 0;
        int other = 0;

        byte[] arr = str.getBytes();
        for (byte s : arr) {
            //System.out.println("s = " + s);
            if (s >= 65 && s <= 90){
                big++;
            }else if (s >= 97 && s <= 122){
                small++;
            }else if (s >= 48 && s <= 57){
                number++;
            }else{
                other++;
            }
        }
        System.out.println("大写字母有" + big + "个");
        System.out.println("小写字母有" + small + "个");
        System.out.println("数字有" + number + "个");
        System.out.println("其他符号有" + other + "个");
    }
}
